home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks95 / Aaron 1.0b3.sit / Aaron 1.0b3 / Aaron Source / CDEF and Patches / DrawButton.c < prev    next >
Text File  |  1995-06-24  |  9KB  |  282 lines

  1. /*    Aaron © 1995 Gregory D. Landweber, ALL RIGHTS RESERVED    */
  2.     
  3. #include "CDEF.h"
  4. #include <Icons.h>
  5.  
  6. void WindowBack ( WindowPtr theWindow, RGBColor *theColor );
  7. pascal void DrawDevelopButton ( GregInfo *theInfo );
  8. void DrawOldStyle ( GregInfo *theInfo, short fore, short back );
  9. void GrayForeColor ( short index );
  10. void GrayBackColor ( short index );
  11.  
  12. void WindowBack ( WindowPtr theWindow, RGBColor *theColor )
  13. {
  14.     AuxWinHandle    theAuxWin;
  15.  
  16.     GetAuxWin ( theWindow, &theAuxWin );    
  17.     GetPartColor ( *(*theAuxWin)->awCTable, theColor, wContentColor );
  18. }
  19.  
  20. pascal void DrawIcon ( short depth, short deviceFlags,
  21.                        GDHandle targetDevice, GregInfo *theInfo )
  22. {
  23.     Rect            theRect = { 0, 0, ButtonSize, ButtonSize };
  24.     CIconHandle    theIcon;
  25.     RGBColor        theColor;
  26.                                 //    normal,             hilited,            disabled
  27.     short        iconID[2][3][2] = {     { { -20239, -20236 }, { -20238, -20235 }, { -20240, -20237 } },        // check
  28.                                 { { -20215, -20214 }, { -20213, -20212 }, { -20211, -20210 } } };    // radio
  29.     short        buttonHilite, buttonValue;
  30.     
  31.     WindowBack ( (*(theInfo->theControl))->contrlOwner, &theColor );
  32.     RGBBackColor ( &theColor );
  33.  
  34.     if ( LoWord(theInfo->msgParam) == inNone )
  35.         EraseRect ( &theInfo->theRect );
  36.     
  37.     DrawTitle ( theInfo, false, false, false );
  38.     
  39.     OffsetRect ( &theRect, theInfo->theRect.left + ButtonLeft,
  40.                 ( theInfo->theRect.bottom + theInfo->theRect.top - ButtonSize ) >> 1 );
  41.  
  42.     buttonValue = (*(theInfo->theControl))->contrlValue;    
  43.     buttonHilite = 0;
  44.     if ( theInfo->pushed )
  45.         buttonHilite = 1;
  46.     if ( theInfo->inActive )
  47.         buttonHilite = 2;
  48.  
  49.     theIcon = GetCIcon ( iconID [theInfo->radio][buttonHilite][buttonValue] );
  50.  
  51.     if ( theIcon ) {
  52.         if ( !theInfo->radio )
  53.             EraseRect (&theRect);
  54.         PlotCIcon (&theRect, theIcon);
  55.         DisposCIcon (theIcon);
  56.     }
  57. }
  58.  
  59. void DrawOldStyle ( GregInfo *theInfo, short fore, short back )
  60. {
  61.     GrayBackColor ( back );
  62.     GrayForeColor ( fore );
  63.         
  64.     EraseRoundRect ( &theInfo->theRect, Radius, Radius );
  65.     FrameRoundRect ( &theInfo->theRect, Radius, Radius );
  66.     DrawTitle ( theInfo, false, false, theInfo->pushed );
  67.     return;
  68. }
  69.  
  70. pascal void DrawButton (short depth, short deviceFlags, GDHandle targetDevice, GregInfo *theInfo)
  71. {    
  72.     if ( ( theInfo->theRect.bottom - theInfo->theRect.top  < 6 ) ||
  73.          ( theInfo->theRect.right  - theInfo->theRect.left < 6 ) ) {
  74.         if ( ( depth >= 4 ) && !theInfo->pushed )
  75.             DrawOldStyle ( theInfo, iFrameColor, 0x0D );
  76.         else
  77.             DrawOldStyle ( theInfo, iFrameColor, 0x0F );
  78.         return;
  79.     }
  80.     
  81.     if ( depth < 4 ) {
  82.         DrawOldStyle ( theInfo, iFrameColor, theInfo->pushed ? 0x00 : 0x0F );
  83.         return;
  84.     }
  85.  
  86.     DrawDevelopButton ( theInfo );
  87. }
  88.  
  89. pascal void DrawDevelopButton ( GregInfo *theInfo )
  90. {
  91.     GrayBackColor ( theInfo->pushed ? 0x08 : 0x0D );
  92.     
  93.     if ( theInfo->inActive ) {
  94.         Rect    theRect = theInfo->theRect;
  95.         
  96.         GrayBackColor ( 0x0D );
  97.         GrayForeColor ( 0x08 );
  98.         EraseRoundRect ( &theRect, Radius, Radius );
  99.         FrameRoundRect ( &theRect, Radius, Radius );
  100.         DrawTitle ( theInfo, false, false, false );
  101.         
  102.         InsetRect ( &theRect, 1, 1 );
  103.         GrayForeColor ( 0x0A );
  104.         MoveTo    ( theRect.left + 2,    theRect.bottom - 1 );
  105.         LineTo    ( theRect.right - 2,    theRect.bottom - 1 );
  106.         LineTo    ( theRect.right - 1,    theRect.bottom - 2 );
  107.         LineTo    ( theRect.right - 1,    theRect.top + 2 );
  108.         MoveTo    ( theRect.right - 2,    theRect.bottom - 2 );
  109.         Line ( 0, 0 );
  110.         
  111.         GrayForeColor ( 0x0B );
  112.         MoveTo    ( theRect.left + 1,    theRect.bottom - 1 );
  113.         LineTo    ( theRect.left,        theRect.bottom - 2 );
  114.         MoveTo    ( theRect.left,        theRect.top + 1 );
  115.         LineTo    ( theRect.left + 1,    theRect.top );
  116.         MoveTo    ( theRect.right - 2,    theRect.top );
  117.         LineTo    ( theRect.right - 1,    theRect.top + 1 );
  118.         
  119.         InsetRect ( &theRect, 1, 1 );
  120.         GrayForeColor ( 0x0F );
  121.         MoveTo    ( theRect.left,        theRect.bottom - 2 );
  122.         LineTo    ( theRect.left,        theRect.top );
  123.         LineTo    ( theRect.right - 2,    theRect.top );
  124.         MoveTo    ( theRect.left + 1,    theRect.top + 1 );
  125.         Line ( 0, 0 );
  126.         
  127.         GrayForeColor ( 0x0B );
  128.         MoveTo    ( theRect.left + 1,    theRect.bottom - 1 );
  129.         LineTo    ( theRect.right - 2,    theRect.bottom - 1 );
  130.         LineTo    ( theRect.right - 1,    theRect.bottom - 2 );
  131.         LineTo    ( theRect.right - 1,    theRect.top + 1 );
  132.         MoveTo    ( theRect.right - 2,    theRect.bottom - 2 );
  133.         Line ( 0, 0 );
  134.         
  135.         return;
  136.     }
  137.  
  138.     GrayForeColor ( 0x00 );
  139.     EraseRoundRect ( &theInfo->theRect, Radius, Radius );
  140.     FrameRoundRect ( &theInfo->theRect, Radius, Radius );
  141.     
  142.     DrawTitle ( theInfo, false, false, false );
  143.     
  144.     if ( theInfo->pushed ) {
  145.         Rect    theRect = theInfo->theRect;
  146.         InsetRect ( &theRect, 1, 1 );
  147.         
  148.         GrayForeColor ( 0x04 );
  149.         MoveTo    ( theRect.left,        theRect.bottom - 3 );
  150.         LineTo    ( theRect.left,        theRect.top + 2 );
  151.         MoveTo    ( theRect.left + 2,    theRect.top );
  152.         LineTo    ( theRect.right - 3,    theRect.top );
  153.         
  154.         GrayForeColor ( 0x0C );
  155.         MoveTo    ( theRect.left + 2,    theRect.bottom - 1 );
  156.         LineTo    ( theRect.right - 2,    theRect.bottom - 1 );
  157.         MoveTo    ( theRect.right - 1,    theRect.bottom - 2 );
  158.         LineTo    ( theRect.right - 1,    theRect.top + 2 );
  159.         MoveTo    ( theRect.right - 2,     theRect.bottom - 2 );
  160.         Line ( 0, 0 );
  161.                 
  162.         GrayForeColor ( 0x05 );
  163.         MoveTo    ( theRect.left + 1,    theRect.bottom - 1 );
  164.         LineTo    ( theRect.left,        theRect.bottom - 2 );
  165.         MoveTo    ( theRect.left,        theRect.top + 1 );
  166.         LineTo    ( theRect.left + 1,    theRect.top );
  167.         MoveTo    ( theRect.right - 2,    theRect.top );
  168.         LineTo    ( theRect.right - 1,    theRect.top + 1 );
  169.         
  170.         InsetRect ( &theRect, 1, 1 );
  171.         
  172.         GrayForeColor ( 0x05 );
  173.         MoveTo     ( theRect.left,        theRect.bottom - 2 );
  174.         LineTo     ( theRect.left,        theRect.top );
  175.         LineTo     ( theRect.right - 2,    theRect.top );
  176.         MoveTo    ( theRect.left + 1,    theRect.top + 1 );
  177.         Line ( 0, 0 );
  178.         
  179.         GrayForeColor ( 0x0A );
  180.         MoveTo    ( theRect.left + 1,    theRect.bottom - 1 );
  181.         LineTo    ( theRect.right - 2,    theRect.bottom - 1 );
  182.         MoveTo    ( theRect.right - 1,    theRect.bottom - 2);
  183.         LineTo    ( theRect.right - 1,    theRect.top + 1 );
  184.         MoveTo    ( theRect.right - 2,    theRect.bottom - 2 );
  185.         Line ( 0, 0 );
  186.     }
  187.     else {
  188.         Rect    theRect = theInfo->theRect;
  189.         InsetRect ( &theRect, 1, 1 );
  190.  
  191.         GrayForeColor ( 0x07 );
  192.         MoveTo    ( theRect.left + 2,    theRect.bottom - 1);
  193.         LineTo    ( theRect.right - 2,    theRect.bottom - 1);
  194.         MoveTo    ( theRect.right - 1,    theRect.bottom - 2 );
  195.         LineTo    ( theRect.right - 1,    theRect.top + 2);
  196.         MoveTo    ( theRect.right - 2,     theRect.bottom - 2 );
  197.         Line ( 0, 0 );
  198.         
  199.         GrayForeColor ( 0x0A );
  200.         MoveTo    ( theRect.left + 1,    theRect.bottom - 1 );
  201.         LineTo    ( theRect.left,        theRect.bottom - 2 );
  202.         MoveTo    ( theRect.left,        theRect.top + 1 );
  203.         LineTo    ( theRect.left + 1,    theRect.top );
  204.         MoveTo    ( theRect.right - 2,    theRect.top );
  205.         LineTo    ( theRect.right - 1,    theRect.top + 1 );
  206.         
  207.         InsetRect ( &theRect, 1, 1 );
  208.         
  209.         GrayForeColor ( 0x0F );
  210.         MoveTo    ( theRect.left,        theRect.bottom - 2 );
  211.         LineTo    ( theRect.left,        theRect.top );
  212.         LineTo    ( theRect.right - 2,    theRect.top );
  213.         MoveTo    ( theRect.left + 1,     theRect.top + 1 );
  214.         Line ( 0, 0 );
  215.         
  216.         GrayForeColor ( 0x0A );
  217.         MoveTo    ( theRect.left + 1,    theRect.bottom - 1 );
  218.         LineTo    ( theRect.right - 2,    theRect.bottom - 1 );
  219.         MoveTo    ( theRect.right - 1,    theRect.bottom - 2 );
  220.         LineTo    ( theRect.right - 1,    theRect.top + 1 );
  221.         MoveTo    ( theRect.right - 2,     theRect.bottom - 2 );
  222.         Line ( 0, 0 );
  223.     }
  224.  
  225.     DrawTitle ( theInfo, true, false, false );
  226.     DrawTitle ( theInfo, false, false, false );
  227.  
  228.     GrayForeColor ( 0x00 );
  229.     FrameRoundRect ( &theInfo->theRect, Radius, Radius );
  230.  
  231.     {
  232.         Rect        theRect = theInfo->theRect;
  233.         
  234.         GrayForeColor ( 0x02 );
  235.         MoveTo    ( theRect.left + 2,    theRect.top );
  236.         Line ( 0, 0 );
  237.         MoveTo    ( theRect.left,        theRect.top + 2 );
  238.         Line ( 0, 0 );
  239.         MoveTo    ( theRect.right - 3,    theRect. top );
  240.         Line ( 0, 0 );
  241.         MoveTo    ( theRect.right - 1,    theRect.top + 2 );
  242.         Line ( 0, 0 );
  243.         MoveTo    ( theRect.left + 2,    theRect.bottom - 1 );
  244.         Line ( 0, 0 );
  245.         MoveTo    ( theRect.left,        theRect.bottom - 3 );
  246.         Line ( 0, 0 );
  247.         MoveTo    ( theRect.right - 3,    theRect.bottom - 1);
  248.         Line ( 0, 0 );
  249.         MoveTo    ( theRect.right - 1,    theRect.bottom - 3 );
  250.         Line ( 0, 0 );
  251.         
  252.     /*
  253.         GrayForeColor ( 0x07 );
  254.         MoveTo    ( theRect.left,        theRect.top + 1 );
  255.         LineTo    ( theRect.left + 1,    theRect.top );
  256.         MoveTo    ( theRect.right - 2,    theRect.top );
  257.         LineTo    ( theRect.right - 1,    theRect.top + 1 );
  258.         MoveTo    ( theRect.right - 1,    theRect.bottom - 2 );
  259.         LineTo    ( theRect.right - 2,    theRect.bottom - 1 );
  260.         MoveTo    ( theRect.left + 1,    theRect.bottom - 1 );
  261.         LineTo    ( theRect.left,        theRect.bottom - 2 );
  262.     */
  263.     }    
  264. }
  265.  
  266. void GrayForeColor ( short index )
  267. {
  268.     RGBColor    theColor;
  269.     
  270.     theColor.red = theColor.green = theColor.blue = 0x1111 * index;
  271.     RGBForeColor ( &theColor );
  272. }
  273.  
  274. void GrayBackColor ( short index )
  275. {
  276.     RGBColor    theColor;
  277.     
  278.     theColor.red = theColor.green = theColor.blue = 0x1111 * index;
  279.     RGBBackColor ( &theColor );
  280. }
  281.  
  282.